﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class frmlaibinqw1 : Form
    {
        public frmlaibinqw1()
        {
            InitializeComponent();
        }
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
    private void button1_Click(object sender, EventArgs e)
        {
            chaxun();
        }
        //查询
    public void chaxun() {
        SqlConnection conn = new SqlConnection(strconn);
        DataSet ds = new DataSet("Student");
        try
        {
            //
            string sql = @"select userName,xfID,xfQi,xfCzid,XfCount,userSex from dbo.Consumption,dbo.UserTpye
where Consumption.xfID=dbo.UserTpye.userID and xfID like'%" + this.txtname.Text + "%'";
            SqlDataAdapter asd = new SqlDataAdapter(sql, conn);
            if (ds.Tables["Student"] != null)
            {
                ds.Tables["Student"].Clear();
            }
            asd.Fill(ds, "Student");
            dataGridView1.DataSource = ds.Tables["Student"];
            //填充前清空数据
           
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    }

    private void frmlaibinqw1_Load(object sender, EventArgs e)
    {

    }


    }
}
